package me.huangxiang.concurrent.nio_demos;

import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;

public class FileChannelDemo {
    public static void main(String[] args) throws IOException {
        RandomAccessFile fromFile = new RandomAccessFile("/home/shareslink-05/Desktop/ardor.txt", "rw");
        FileChannel fromChannel = fromFile.getChannel();
        long size = fromChannel.size();

        RandomAccessFile toFile = new RandomAccessFile("/home/shareslink-05/Desktop/to.txt", "rw");
        FileChannel toChannel = toFile.getChannel();

//        toChannel.transferFrom(fromChannel, 0, size);
        fromChannel.transferTo(0, size, toChannel);
    }
}
